import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

/**
 * Created by User on 07.05.14.
 */
public class ShowInConsole {
    private ManagerDeployee md;
    private List<String> list;
    private String value;
    private boolean wh;
    private Boolean b;

    public ShowInConsole() {
        md = new ManagerDeployee();
        list = FileMaster.getFileContent(md.getPATH());
        SalaryManager sm = new SalaryManager();
        wh = true;
        do {
            //получаем список рабочих из файла

            show();
            Scanner sc = new Scanner(System.in);
            value = sc.nextLine();
            int a = Integer.parseInt(value);
            switch (a) {
                case (0):
                    wh = false;
                    break;
                case (1): {
                    Iterator<String> it = list.iterator();
                    while (it.hasNext()){
                        System.out.println(it.next() + "\n");}

                    break;
                }
                case (2): {
                    System.out.println("Enter the name new deployeer");
                    String name = sc.nextLine();
                    System.out.println("Enter the ktu for new deployeer");
                    Double ktu = Double.parseDouble(sc.nextLine());
                    System.out.println("Enter the local for new deployeer");
                    String local = sc.nextLine();

                    b = md.addDeployee(name, ktu, local);
                    if (b)
                        System.out.println("New deployeer add in this list.");
                    else System.out.println("Sorry. Ecxeption.");

                    break;
                }
                case (3): {
                    System.out.println("Enter the name deployeer, for you want delete:");
                    boolean fl = md.delDeploy(sc.nextLine());
                    if (fl) {
                        System.out.println("Deployye delete in List.");
                    } else System.out.print("Sorry, this deployee not find in list");

                    break;
                }
                case (4): {


                    System.out.println(sm.midKTU());
                    break;
                }
                case (5): {
                    System.out.println("Enter total SUM money:");
                    Double sal;
                    String val = sc.nextLine();
                    sal = Double.parseDouble(val);
                    if(sal>0){
                    sm.persSalary(sal);
                    List<String> listSal = FileMaster.getFileContent(md.getPATH1());
                    Iterator<String> it = listSal.iterator();
                    while (it.hasNext()){
                        System.out.println(it.next());
                        System.out.println();
                    }                                     }
                    break;
                }
            }
        } while (wh);


    }

    public static void show() {
        System.out.println("     ------------------------------");
        System.out.println("     ------------------------------");
        System.out.println("           Show list deployees - press 1");
        System.out.println("     ------------------------------");
        System.out.println("             Add new deployees - press 2");
        System.out.println("     ------------------------------");
        System.out.println("               Delete deployee - press 3");
        System.out.println("     ------------------------------");
        System.out.println("        Show midle ktu company - press 4");
        System.out.println("     ------------------------------");
        System.out.println("For will think personal salary - press 5");
        System.out.println("     ------------------------------");
        System.out.println("                          Exit - press 0");
        System.out.println("     ------------------------------");
        System.out.println("     ------------------------------");

    }
}
